﻿#region

using Vin.Extension.Framework.Login.Entities;
using Vin.Extension.Framework.Repository;

#endregion

namespace Vin.Extension.Framework.Login.Repository;

/// <summary>
/// 账号绑定仓储
/// </summary>
public class SysAccountBindRepository : VinFrameworkBaseRepository<SysAccountBind>
{
    public async Task<bool> CheckCanBindAsync(string bindType, string bindValue)
    {
        return await GetFirstAsync(m => m.BindType == bindType && m.BindValue == bindValue) == null;
    }

    public async Task<SysAccountBind?> QueryByBindTypeAsync(long accountId, string bindType)
    {
        return await GetFirstAsync(m => m.AccountId == accountId && m.BindType == bindType);
    }

    public async Task<long?> QueryByBindAsync(string bindType, string bindValue)
    {
        return (await GetFirstAsync(m => m.BindType == bindType && m.BindValue == bindValue))?.AccountId;
    }
}